package com.qzsoft.system.modules.qywechat.controller;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.qzsoft.jeemis.common.utils.Result;
import com.qzsoft.jeemis.platform.security.service.BasicUserService;
import com.qzsoft.jeemis.platform.security.service.BasicUserTokenService;
import com.qzsoft.jeemis.repository.sys.entity.BasicUserEntity;

/**
 * @ClassName QyWechatController
 * @Description 企业微信控制器
 * @author linhuawei
 * @since 2022-05-07
 */
@RestController
@RequestMapping("/api/qyWechat")
public class QyWechatController {

    @Autowired
    private BasicUserService basicUserService;

    @Autowired
    private BasicUserTokenService sysUserTokenService;

    /**
     * @Title login
     * @Description 第三方应用登录获取token信息
     * @param request
     * @param login
     * @return
     */
    @PostMapping("login")
    public Result<?> login(HttpServletRequest request) {
        BasicUserEntity user = this.basicUserService.getByUsername("admin");
        return sysUserTokenService.createToken(user.getId(), user.getUsername(), user.getPassword());
    }

}
